<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition 


        template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListProjectsTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>
                <h:outputText escape="false" value="#{bundle.ListProjectsEmpty}" rendered="#{projectsController.items.rowCount == 0}"/>
                <h:panelGroup id ="panelSearch" rendered="#{projectsController.items.rowCount > 0}">
                    <h:outputText value="#{projectsController.pagination.pageFirstItem + 1}..#{projectsController.pagination.pageLastItem + 1}/#{projectsController.pagination.itemsCount}"/>&nbsp;
                    <h:commandLink action="#{projectsController.previous}" value="#{bundle.Previous} #{projectsController.pagination.pageSize}" rendered="#{projectsController.pagination.hasPreviousPage}"/>&nbsp;
                    <h:commandLink action="#{projectsController.next}" value="#{bundle.Next} #{projectsController.pagination.pageSize}" rendered="#{projectsController.pagination.hasNextPage}"/>&nbsp;
                    <h:dataTable   value="#{projectsController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListProjectsTitle_projectCode}"/>
                            </f:facet>
                            <h:outputText value="#{item.projectCode}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListProjectsTitle_projectName}"/>
                            </f:facet>
                            <h:outputText value="#{item.projectName}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListProjectsTitle_activityCode}"/>
                            </f:facet>
                            <h:outputText value="#{item.activityCode}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListProjectsTitle_createdAt}"/>
                            </f:facet>
                            <h:outputText value="#{item.createdAt}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListProjectsTitle_status}"/>
                            </f:facet>
                            <h:outputText value="#{item.status}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListProjectsTitle_customer}"/>
                            </f:facet>
                            <h:outputText value="#{item.customer.name}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListProjectsTitle_createdBy}"/>
                            </f:facet>
                            <h:outputText value="#{item.createdBy.businessEmail}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandLink action="#{projectsController.prepareView}" value="#{bundle.ListProjectsViewLink}"/>
                            <h:outputText value=" "/>
                            <h:commandLink action="#{projectsController.prepareEdit}" value="#{bundle.ListProjectsEditLink}"/>
                            <h:outputText value=" "/>
                            <h:commandLink action="#{projectsController.destroy}" value="#{bundle.ListProjectsDestroyLink}"/>
                        </h:column>

                    </h:dataTable>
                </h:panelGroup>
                <br />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <h:commandButton type="submit" action="#{projectsController.prepareCreate}" value="#{bundle.ListProjectsCreateLink}"/>
                <h:button value="Search" outcome="Search" />
                <h:button rendered="${type=='admin'}" value="Back to Home" outcome="/index" />
            </h:form>
        </ui:define>
    </ui:composition>

</html>
